<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:a4j="http://richfaces.org/a4j"
                xmlns:rich="http://richfaces.org/rich">
    <style>
        .col, .col2 {
            width:50%;
            vertical-align:top;
        }
        .gridhello {
            border-collapse : collapse;
        }
        .gridhellocolumn {
            padding-left : 0;
        }
        .pic{
            margin-bottom: -4px;
            margin-right: 2px;
            border:none;
        }
    </style>
    <script type="text/javascript">
        function delConfirm() {
            return confirm("确定要删除吗？");
        }
    </script>
    <h:form>
        <rich:panel header="文档类型管理" styleClass="content-hight">
            <rich:toolbar>
                <rich:toolbarGroup>
                    <a4j:commandButton value="新增" render="edit" action="#{documentType.add}">
                    </a4j:commandButton>
                    <a4j:commandButton value="修改" render="edit" action="#{documentType.update}">
                    </a4j:commandButton>
                    <a4j:commandButton value="删除" render="edit" action="#{documentType.del}">
                    </a4j:commandButton>
                    <a4j:commandButton value="保存" render="edit"  action="#{documentType.save}">
                    </a4j:commandButton>
                    <a4j:commandButton value="取消" render="edit" action="#{documentType.cancel}"/>
                </rich:toolbarGroup>
            </rich:toolbar>

            <h:panelGrid columns="2" width="100%" columnClasses="col1,col2"  id="edit">
                <rich:tree style="width:300px"
                           render="documentTypeInfo"
                           value="#{documentType.treeNode}"
                           selectionChangeListener="#{documentType.selected2}"
                           var="idocumentType">
                    <rich:treeNode>
                        <h:outputText value="[#{idocumentType.data.id}]#{idocumentType.data.name}" />
                    </rich:treeNode>
                    <a4j:ajax event="click" render="editTable"/>
                </rich:tree>
                <h:panelGroup>
                    <h:panelGrid columns="3" id="documentTypeInfo">
                        <h:outputText value="代码："/>
                        <h:outputText rendered="#{documentType.showAble}" value="#{documentType.documentType.id}"/>
                        <h:inputText rendered="#{documentType.editAble}" binding="#{documentType.documentTypeCode}"
                                     id="documenttypecode" value="#{documentType.documentType.id}">
                        </h:inputText>
                        <h:message for="documenttypecode"/>

                        <h:outputText value="名称："/>
                        <h:outputText rendered="#{documentType.showAble}" value="#{documentType.documentType.name}"/>
                        <h:inputText rendered="#{documentType.editAble}" id="documenttypename"
                                     value="#{documentType.documentType.name}"/>
                        <h:message for="documenttypename"/>
                        <h:outputLabel value="说明："/>
                        <h:outputLabel value="编码命名规则为11-11-11-11-11"/>
                    </h:panelGrid>
                </h:panelGroup>
            </h:panelGrid>

            <h:outputLabel value="警告：" />
            <rich:message/><br/><br/>


            <hr/>
            <h:panelGroup id="editTable">
                <rich:dataTable value="#{documentType.doclist}" var="doc"
                                rows="10"
                                style="width:100%;">
                    <rich:column sortBy="#{doc.id}">
                        <f:facet name="header">
                            <h:panelGroup>
                                <h:outputText value="代码"/>
                            </h:panelGroup>
                        </f:facet>
                        <h:outputText value="#{doc.id}"/>
                    </rich:column>
                    <rich:column sortBy="#{doc.title}">
                        <f:facet name="header">
                            <h:panelGroup>
                                <h:outputText value="文档标题"/>
                            </h:panelGroup>
                        </f:facet>
                        <h:outputText value="#{doc.title}"/>
                    </rich:column>
                    <rich:column sortBy="#{doc.uploadDate}">
                        <f:facet name="header">
                            <h:panelGroup>
                                <h:outputText value="上传日期"/>
                            </h:panelGroup>
                        </f:facet>
                        <h:outputText value="#{doc.uploadDate}">
                            <f:convertDateTime timeZone="GMT+8" dateStyle="medium"/>
                        </h:outputText>
                    </rich:column>
                    <rich:column sortBy="#{doc.userName}">
                        <f:facet name="header">
                            <h:panelGroup>
                                <h:outputText value="上传人员"/>
                            </h:panelGroup>
                        </f:facet>
                        <h:outputText value="#{doc.userName}"/>
                    </rich:column>
                    <rich:column sortBy="#{doc.docSize}">
                        <f:facet name="header">
                            <h:panelGroup>
                                <h:outputText value="文件大小"/>
                            </h:panelGroup>
                        </f:facet>
                        <h:outputText value="#{doc.docSize}"/>
                    </rich:column>
                    <rich:column sortBy="#{doc.description}">
                        <f:facet name="header">
                            <h:panelGroup>
                                <h:outputText value="文档描述"/>
                            </h:panelGroup>
                        </f:facet>
                        <h:outputText value="#{doc.description}"/>
                    </rich:column>
                    <rich:column sortBy="#{doc.type.id}">
                        <f:facet name="header">
                            <h:panelGroup>
                                <h:outputText value="文档状态"/>
                            </h:panelGroup>
                        </f:facet>
                        <h:outputText value="文档已不存在" rendered="#{doc.showflag==false}"/>
                        <h:outputText value="正常" rendered="#{doc.showflag==true}"/>
                    </rich:column>
                    <rich:column style="white-space: nowrap;">
                        <f:facet name="header">
                            <h:panelGroup>
                                <h:outputText value="操作"/>
                            </h:panelGroup>
                        </f:facet>
                        <h:panelGrid columns="7">
                            【<h:commandLink value="删除" action="#{documentType.deleteDocument(doc)}"
                                            onclick="return delConfirm();">
                            </h:commandLink>】
                            -
                            【<h:commandLink rendered="#{doc.showflag}" action="#{documentUpdateBean.download(doc)}">
                                <h:outputText value="下载" rendered="#{doc.showflag}"/>
                            </h:commandLink>
                            <h:outputText value="文档已不存在" rendered="#{doc.showflag==false}"/>】
                        </h:panelGrid>
                    </rich:column>
                    <f:facet name="footer">
                        <rich:dataScroller id="ds"></rich:dataScroller>
                    </f:facet>
                </rich:dataTable>
            </h:panelGroup>
        </rich:panel>
    </h:form>

</ui:composition>
